﻿<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class luongcanbo_Model extends Model {

    function __construct()
    {
        parent::__construct();
    }
    public function SELECT_HSLCB_BY_MDV_ALL_TR($P_MA_DON_VI){
        $P_SITE_ROOT = SITE_ROOT;
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSLCB_BY_MDV_ALL_TR
                                                      (:CUR,
                                                      '$P_MA_DON_VI',
                                                      '$P_SITE_ROOT'
                                                      );END;",'CUR');
    }
    public function SELECT_HSLCB_BY_MTCM_ALL_TR($P_MA_DON_VI,$P_MA_TO_CHUYEN_MON){
        $P_SITE_ROOT = SITE_ROOT;
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSLCB_BY_MTCM_ALL_TR
                                                      (:CUR,
                                                      '$P_MA_DON_VI',
                                                      $P_MA_TO_CHUYEN_MON,
                                                      '$P_SITE_ROOT'
                                                      );END;",'CUR');
    }
    public function SELECT_HSLCB_BY_MTCM_ALL_TR2($P_MA_TO_CHUYEN_MON){
        $P_SITE_ROOT = SITE_ROOT;
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSLCB_BY_MTCM_ALL_TR2
                                                      (:CUR,
                                                      $P_MA_TO_CHUYEN_MON,
                                                      '$P_SITE_ROOT'
                                                      );END;",'CUR');
    }
    /****************************form dsp_quatrinhluong_canbo***********************/
     public function SELECT_HSL_BY_MA_BAC_NGACH($P_MA_BAC_NGACH) {
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSL_BY_MA_BAC_NGACH(:CUR,$P_MA_BAC_NGACH); END;", 'CUR');
     }
     public function SELECT_BAC_NGACH_HIEN_TAI($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_BAC_NGACH_HIEN_TAI(:CUR,'$MA_CAN_BO'); END;",'CUR');
     }
     public function SELECT_QUA_TRINH_TANG_LUONG($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_QUA_TRINH_TANG_LUONG(:CUR,$MA_CAN_BO); END;",'CUR');
     }
     public function capnhat_HSLmoi(){
       $P_NGUOI_CAP_NHAT = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
       $P_MA_CAN_BO = get_post_var('hdn_item_id');
       $P_MA_BAC_NGACH = get_post_var('cbx_MA_NGACH_MOI');
       $P_HE_SO_LUONG = get_post_var('txt_HSL_MOI');
       $P_THANG_BAT_DAU_AP_DUNG = get_post_var('txt_THANG_BAT_DAU_MOI');
       $P_NAM_BAT_DAU_AP_DUNG = get_post_var('txt_NAM_BAT_DAU_MOI');
       $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG2.UPDATE_HSL_MOI(:P_VAL,
                                                               :P_NGUOI_CAP_NHAT,
                                                               :P_MA_CAN_BO,
                                                               :P_MA_BAC_NGACH,
                                                               :P_HE_SO_LUONG,
                                                               :P_THANG_BAT_DAU_AP_DUNG,
                                                               :P_NAM_BAT_DAU_AP_DUNG
                                                               );END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_NGUOI_CAP_NHAT,'P_NGUOI_CAP_NHAT');
        $this->db->InParameter($stmt,$P_MA_CAN_BO,'P_MA_CAN_BO');
        $this->db->InParameter($stmt,$P_MA_BAC_NGACH,'P_MA_BAC_NGACH');
        $this->db->InParameter($stmt,$P_HE_SO_LUONG,'P_HE_SO_LUONG');
        $this->db->InParameter($stmt,$P_THANG_BAT_DAU_AP_DUNG,'P_THANG_BAT_DAU_AP_DUNG');
        $this->db->InParameter($stmt,$P_NAM_BAT_DAU_AP_DUNG,'P_NAM_BAT_DAU_AP_DUNG');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->popup_exec_done();
          }else{
               $this->popup_exec_fail('Không thể cập nhật!');
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->popup_exec_fail('Không thể cập nhật! Lỗi database');
            return;
        }

    }
    /****************************form dsp_quatrinhPCCV_canbo***********************/
     public function SELECT_HSPCCV_BY_MA_PCCV($P_MA_PHU_CAP_CHUC_VU) {
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSPCCV_BY_MA_PCCV(:CUR,$P_MA_PHU_CAP_CHUC_VU); END;", 'CUR');
     }
     public function SELECT_PCCV_HIEN_TAI($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_PCCV_HIEN_TAI(:CUR,'$MA_CAN_BO'); END;",'CUR');
     }
     public function SELECT_QUA_TRINH_PCCV($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_QUA_TRINH_PCCV(:CUR,$MA_CAN_BO); END;",'CUR');
     }
     public function capnhat_HSPCCVmoi(){
       $P_NGUOI_CAP_NHAT = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
       $P_MA_CAN_BO = get_post_var('hdn_item_id');
       $P_MA_PHU_CAP_CHUC_VU = get_post_var('cbx_MA_PCCV_MOI');
       $P_HE_SO_PHU_CAP_CHUC_VU = get_post_var('txt_HSPCCV_MOI');
       $P_THANG_BAT_DAU_AP_DUNG = get_post_var('txt_THANG_BAT_DAU_MOI');
       $P_NAM_BAT_DAU_AP_DUNG = get_post_var('txt_NAM_BAT_DAU_MOI');
       $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG2.UPDATE_HSPCCV_MOI(:P_VAL,
                                                               :P_NGUOI_CAP_NHAT,
                                                               :P_MA_CAN_BO,
                                                               :P_MA_PHU_CAP_CHUC_VU,
                                                               :P_HE_SO_PHU_CAP_CHUC_VU,
                                                               :P_THANG_BAT_DAU_AP_DUNG,
                                                               :P_NAM_BAT_DAU_AP_DUNG
                                                               );END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_NGUOI_CAP_NHAT,'P_NGUOI_CAP_NHAT');
        $this->db->InParameter($stmt,$P_MA_CAN_BO,'P_MA_CAN_BO');
        $this->db->InParameter($stmt,$P_MA_PHU_CAP_CHUC_VU,'P_MA_PHU_CAP_CHUC_VU');
        $this->db->InParameter($stmt,$P_HE_SO_PHU_CAP_CHUC_VU,'P_HE_SO_PHU_CAP_CHUC_VU');
        $this->db->InParameter($stmt,$P_THANG_BAT_DAU_AP_DUNG,'P_THANG_BAT_DAU_AP_DUNG');
        $this->db->InParameter($stmt,$P_NAM_BAT_DAU_AP_DUNG,'P_NAM_BAT_DAU_AP_DUNG');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->popup_exec_done();
          }else{
               $this->popup_exec_fail('Không thể cập nhật!');
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->popup_exec_fail('Không thể cập nhật! Lỗi database');
            return;
        }

    }
    /****************************form dsp_quatrinhPCUD_canbo***********************/
     public function SELECT_HSPCTN_BY_MA_PCUD($P_MA_PHU_CAP_UU_DAI) {
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSPCUD_BY_MA_PCUD(:CUR,$P_MA_PHU_CAP_UU_DAI); END;", 'CUR');
     }
     public function SELECT_PCUD_HIEN_TAI($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_PCUD_HIEN_TAI(:CUR,'$MA_CAN_BO'); END;",'CUR');
     }
     public function SELECT_QUA_TRINH_PCUD($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_QUA_TRINH_PCUD(:CUR,$MA_CAN_BO); END;",'CUR');
     }
     public function capnhat_HSPCUDmoi(){
       $P_NGUOI_CAP_NHAT = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
       $P_MA_CAN_BO = get_post_var('hdn_item_id');
       $P_MA_PHU_CAP_UU_DAI = get_post_var('cbx_MA_PCUD_MOI');
       $P_HE_SO_PHU_CAP_UU_DAI = get_post_var('txt_HSPCUD_MOI');
       $P_THANG_BAT_DAU_AP_DUNG = get_post_var('txt_THANG_BAT_DAU_MOI');
       $P_NAM_BAT_DAU_AP_DUNG = get_post_var('txt_NAM_BAT_DAU_MOI');
       $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG2.UPDATE_HSPCUD_MOI(:P_VAL,
                                                               :P_NGUOI_CAP_NHAT,
                                                               :P_MA_CAN_BO,
                                                               :P_MA_PHU_CAP_UU_DAI,
                                                               :P_HE_SO_PHU_CAP_UU_DAI,
                                                               :P_THANG_BAT_DAU_AP_DUNG,
                                                               :P_NAM_BAT_DAU_AP_DUNG
                                                               );END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_NGUOI_CAP_NHAT,'P_NGUOI_CAP_NHAT');
        $this->db->InParameter($stmt,$P_MA_CAN_BO,'P_MA_CAN_BO');
        $this->db->InParameter($stmt,$P_MA_PHU_CAP_UU_DAI,'P_MA_PHU_CAP_UU_DAI');
        $this->db->InParameter($stmt,$P_HE_SO_PHU_CAP_UU_DAI,'P_HE_SO_PHU_CAP_UU_DAI');
        $this->db->InParameter($stmt,$P_THANG_BAT_DAU_AP_DUNG,'P_THANG_BAT_DAU_AP_DUNG');
        $this->db->InParameter($stmt,$P_NAM_BAT_DAU_AP_DUNG,'P_NAM_BAT_DAU_AP_DUNG');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->popup_exec_done();
          }else{
               $this->popup_exec_fail('Không thể cập nhật!');
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->popup_exec_fail('Không thể cập nhật! Lỗi database');
            return;
        }

    }
    /****************************form dsp_quatrinhPCTN_canbo***********************/
     public function SELECT_HSPCTN_BY_MA_PCTN($P_MA_PHU_CAP_TRACH_NHIEM) {
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_HSPCTN_BY_MA_PCTN(:CUR,$P_MA_PHU_CAP_TRACH_NHIEM); END;", 'CUR');
     }
     public function SELECT_PCTN_HIEN_TAI($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_PCTN_HIEN_TAI(:CUR,'$MA_CAN_BO'); END;",'CUR');
     }
     public function SELECT_QUA_TRINH_PCTN($MA_CAN_BO){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG2.SELECT_QUA_TRINH_PCTN(:CUR,$MA_CAN_BO); END;",'CUR');
     }
     public function capnhat_HSPCTNmoi(){
       $P_NGUOI_CAP_NHAT = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
       $P_MA_CAN_BO = get_post_var('hdn_item_id');
       $P_MA_PHU_CAP_TRACH_NHIEM = get_post_var('cbx_MA_PCTN_MOI');
       $P_HE_SO_PHU_CAP_TRACH_NHIEM = get_post_var('txt_HSPCTN_MOI');
       $P_THANG_BAT_DAU_AP_DUNG = get_post_var('txt_THANG_BAT_DAU_MOI');
       $P_NAM_BAT_DAU_AP_DUNG = get_post_var('txt_NAM_BAT_DAU_MOI');
       $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG2.UPDATE_HSPCTN_MOI(:P_VAL,
                                                               :P_NGUOI_CAP_NHAT,
                                                               :P_MA_CAN_BO,
                                                               :P_MA_PHU_CAP_TRACH_NHIEM,
                                                               :P_HE_SO_PHU_CAP_TRACH_NHIEM,
                                                               :P_THANG_BAT_DAU_AP_DUNG,
                                                               :P_NAM_BAT_DAU_AP_DUNG
                                                               );END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_NGUOI_CAP_NHAT,'P_NGUOI_CAP_NHAT');
        $this->db->InParameter($stmt,$P_MA_CAN_BO,'P_MA_CAN_BO');
        $this->db->InParameter($stmt,$P_MA_PHU_CAP_TRACH_NHIEM,'P_MA_PHU_CAP_TRACH_NHIEM');
        $this->db->InParameter($stmt,$P_HE_SO_PHU_CAP_TRACH_NHIEM,'P_HE_SO_PHU_CAP_TRACH_NHIEM');
        $this->db->InParameter($stmt,$P_THANG_BAT_DAU_AP_DUNG,'P_THANG_BAT_DAU_AP_DUNG');
        $this->db->InParameter($stmt,$P_NAM_BAT_DAU_AP_DUNG,'P_NAM_BAT_DAU_AP_DUNG');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->popup_exec_done();
          }else{
               $this->popup_exec_fail('Không thể cập nhật!');
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->popup_exec_fail('Không thể cập nhật! Lỗi database');
            return;
        }

    }
}